﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class Recharge : IAccessible<T_Recharge, Recharge>, ILogicEntity<T_Recharge,Recharge>
    {
        public int Id { get; set; }
        public string UserName { get; set; }
        public decimal RechargeValue { get; set; }
        public DateTime RechargeDate { get; set; }
        public int PayType { get; set; }
        public string Remark { get; set; }
        public decimal Balance { get; set; }

        protected override void Covariant(T_Recharge model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.UserName = model.UserName;
                this.RechargeDate = model.RechargeDate;
                this.RechargeValue = model.RechargeValue;
                this.PayType = model.PayType;
                this.Remark = model.Remark;
                this.Balance = model.Balance;
            }
        }

        protected override T_Recharge Inverter(Recharge model)
        {
            if (model != null)
            {
                return new T_Recharge()
                {
                    Balance = model.Balance,
                    Id = model.Id,
                    PayType = model.PayType,
                    RechargeDate = model.RechargeDate,
                    RechargeValue = model.RechargeValue,
                    Remark = model.Remark,
                    UserName = model.UserName
                };
            }
            return null;
        }

        public Recharge Set(T_Recharge dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
